package io.renren.modules.app.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.BsBorrviolationEntity;
import io.renren.modules.app.service.BsBorrviolationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 * 借阅违约信息表
 *
 * @author zwl
 * @email ${email}
 * @date 2024-01-02 18:30:55
 */
@RestController
@RequestMapping("bs_borrviolation/bsborrviolation")
public class BsBorrviolationController {
    @Autowired
    private BsBorrviolationService bsBorrviolationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("bs_borrviolation:bsborrviolation:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bsBorrviolationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("bs_borrviolation:bsborrviolation:info")
    public R info(@PathVariable("id") Integer id){
		BsBorrviolationEntity bsBorrviolation = bsBorrviolationService.getById(id);

        return R.ok().put("bsBorrviolation", bsBorrviolation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("bs_borrviolation:bsborrviolation:save")
    public R save(@RequestBody BsBorrviolationEntity bsBorrviolation){
        bsBorrviolation.setUpdateTime(new Date());
        bsBorrviolation.setCreateTime(new Date());
		bsBorrviolationService.save(bsBorrviolation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("bs_borrviolation:bsborrviolation:update")
    public R update(@RequestBody BsBorrviolationEntity bsBorrviolation){
        bsBorrviolation.setUpdateTime(new Date());
//		bsBorrviolationService.updateById(bsBorrviolation);
        bsBorrviolationService.updateBsBorrviolationEntity(bsBorrviolation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("bs_borrviolation:bsborrviolation:delete")
    public R delete(@RequestBody Integer[] ids){
		bsBorrviolationService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
